﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using NUnit.Framework;


namespace ReducaoPena.UnitTest {
	
	[TestFixture]
	public class ValidaResultados {

		[Test]
		public void Teste_3_Tarefas() {
			
			String strt = @"3
5000 10 Seg 08:00 23:00
5001 20 Seg 11:00 12:00
5002 15 Seg 23:01 23:30";
			
			List<Int32> diasPontos;
			Int32 total;
			
			TarefaCollection tc = this.ParseTarefas(strt);
			tc.GetBestPontuation(out diasPontos, out total);
			
			Assert.AreEqual(35, diasPontos[0]);
			Assert.AreEqual(0, diasPontos[1]);
			Assert.AreEqual(0, diasPontos[2]);
			Assert.AreEqual(0, diasPontos[3]);
			Assert.AreEqual(0, diasPontos[4]);
			Assert.AreEqual(35, total);
		}

		[Test]
		public void Teste_4_Tarefas() {

			String strt = @"4
1977 5 Qua 10:00 10:29
1980 10 Qua 10:15 11:15
1983 6 Qua 11:00 12:00
1000 10 Seg 13:00 22:00";

			List<Int32> diasPontos;
			Int32 total;

			TarefaCollection tc = this.ParseTarefas(strt);
			tc.GetBestPontuation(out diasPontos, out total);

			Assert.AreEqual(10, diasPontos[0]);
			Assert.AreEqual(0, diasPontos[1]);
			Assert.AreEqual(11, diasPontos[2]);
			Assert.AreEqual(0, diasPontos[3]);
			Assert.AreEqual(0, diasPontos[4]);
			Assert.AreEqual(21, total);
		}

		[Test]
		public void Teste_10_Tarefas() {

			String strt = @"10
1 16 Seg 17:53 19:09
2 23 Ter 14:12 22:16
3 46 Qua 22:55 23:15
4 22 Qua 02:29 04:46
5 8 Ter 03:58 23:38
6 11 Ter 11:44 18:45
7 20 Ter 20:48 23:10
8 5 Qua 03:10 10:54
9 49 Sex 01:57 16:23
10 41 Ter 08:29 14:46";

			List<Int32> diasPontos;
			Int32 total;

			TarefaCollection tc = this.ParseTarefas(strt);
			tc.GetBestPontuation(out diasPontos, out total);

			Assert.AreEqual(16, diasPontos[0]);
			Assert.AreEqual(61, diasPontos[1]);
			Assert.AreEqual(68, diasPontos[2]);
			Assert.AreEqual(0, diasPontos[3]);
			Assert.AreEqual(49, diasPontos[4]);
			Assert.AreEqual(194, total);
		}
		
		private TarefaCollection ParseTarefas(String strTarefas){
			Int32 qtd = 0;
			String aux;
			String[] data;
			StringReader reader = new StringReader(strTarefas);
			TarefaCollection list = new TarefaCollection();
			
			aux = reader.ReadLine();
			qtd = Int32.Parse(aux.Trim());

			for (int i = 0; i < qtd; i++) {
				aux = reader.ReadLine().Trim();
				data = aux.Split(' ');

				Tarefa t = new Tarefa(Int32.Parse(data[0]), Int32.Parse(data[1]), data[2], data[3], data[4]);
				list.Add(t);
			}
			
			reader.Close();
			return list;
		}
		
		[SetUp]
		public void Init() {

		}

		[TearDown]
		public void Finalize() {

		}
	}
}
